﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.Master" AutoEventWireup="true" CodeBehind="AdministracionDeTareas.aspx.cs" Inherits="SistemaWeb.Paginas.ListaTareas" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register src="../Editores/EdTarea.ascx" tagname="EdTarea" tagprefix="uc2" %>
<%@ Register src="../Editores/EdAsignacionTarea.ascx" tagname="EdAsignacionTarea" tagprefix="uc1" %>
<asp:Content runat="server" ID="contenido" ContentPlaceHolderID="MainContent">
    
    <script type="text/javascript"">
        function CommandControler(command, record)
        {            
            if(command == 'Edit')
            {
                Coolite.AjaxMethods.CargarPopupEditor(record.data.id);
            }
            if(command == 'Delete')
            {               
               Ext.MessageBox.confirm('Confirmar Eliminación', 'Se esta por eliminar una tarea, desea continuar?', function(btn){
                    if (btn == 'yes') 
                    {
                        Coolite.AjaxMethods.EliminarTarea(record.data.id); 
                    }
                    else
                    {
                        return false;
                    }
                });  
            }
            if(command == 'AddResource')
            {
                Coolite.AjaxMethods.CargarPopupAsignacion(record.data.id);
            }                
        }        
        
        var prepare = function (grid, toolbar, rowIndex, record) {
            var firstButton = toolbar.items.get(0);            
            if (role.toString() != "Administrador" && role.toString() != "Project Manager") {
                firstButton.setDisabled(true);
                firstButton.setTooltip('Disabled');
            }
            
            //you can return false to cancel toolbar for this record
        }        
  
    </script>


    <ext:Store ID="Store1" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="id">
                <Fields>
                    <ext:RecordField Name="id" />
                    <ext:RecordField Name="nombre" />
                    <ext:RecordField Name="descripcion" />
                    <ext:RecordField Name="tipo" />
                    <ext:RecordField Name="prioridad" />
                    <ext:RecordField Name="complejidad" />
                    <ext:RecordField Name="perfil" />
                    <ext:RecordField Name="seniority" />
                    <ext:RecordField Name="estado" />
                    <ext:RecordField Name="proyecto" />
                    <ext:RecordField Name="fechaCreacion" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    <table id="layout" runat="server" width="100%" >
        <tr>    
            <td style="vertical-align:top">
                <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true" Icon="Vcard" 
                    Title="Tareas del Proyecto" TrackMouseOver="true" Width="810" Height="375">
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column ColumnID="ID" Header="id" Sortable="true" DataIndex="id" Width="50" />
                            <ext:Column Header="Tarea" Sortable="true" DataIndex="nombre" Width="450" />
                            <ext:Column Header="Tipo" Sortable="true" DataIndex="tipo" Width="100" />
                            <ext:Column Header="Prioridad" Sortable="true" DataIndex="prioridad" Width="100" />
                            <ext:CommandColumn Width="100" Header="Accion">
                                <Commands>
                                    <ext:GridCommand Icon="BulletCross" CommandName="Delete">                                        
                                        <ToolTip Text="Advertencia, al clickear en este boton borrara la Tarea!" Title="Eliminar Tarea" />
                                    </ext:GridCommand>
                                    <ext:CommandSeparator />
                                    <ext:GridCommand Icon="BulletEdit"  CommandName="Edit">
                                        <ToolTip Text="Haga clic para editar esta tarea" Title="Editar Tarea" />
                                    </ext:GridCommand>
                                    <ext:CommandSeparator />
                                    <ext:GridCommand Icon="UserAdd"  CommandName="AddResource">
                                        <ToolTip Text="Haga clic para asignar recursos humanos a esta tarea, o para ver los recursos que ya tiene asignados." Title="Asignación de Recursos" />
                                    </ext:GridCommand>
                                </Commands>
                                <PrepareToolbar Fn="prepare" />  
                            </ext:CommandColumn>                           
                        </Columns>
                    </ColumnModel>
                    <Listeners>
                        <Command Handler="CommandControler(command, record);" />
                    </Listeners>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                            <AjaxEvents>
                                <RowSelect OnEvent="RowSelect" Buffer="250">
                                    <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{Details}" />
                                    <ExtraParams>
                                        <ext:Parameter Name="ID" Value="this.getSelected().id" Mode="Raw" />
                                    </ExtraParams>
                                </RowSelect>
                            </AjaxEvents>
                        </ext:RowSelectionModel>
                    </SelectionModel>
                    <LoadMask ShowMask="true" />
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolBar1" runat="server" PageSize="12" StoreID="Store1" />
                    </BottomBar>
                </ext:GridPanel>               
            </td>
            <td>
                <ext:Panel 
                            ID="Details" 
                            runat="server" 
                            Frame="true" 
                            Title="Tarea Detalle" 
                            Width="280"
                            Icon="VcardAdd"
                            Height="375">                           
                            <Body>
                                <ext:FormLayout ID="FormLayout1" runat="server">
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="idTB" 
                                            runat="server" 
                                            FieldLabel="ID" 
                                            Width="150"
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="nombreTB" 
                                            runat="server" 
                                            FieldLabel="Tarea" 
                                            Width="150"
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="prioridadTB" 
                                            runat="server" 
                                            FieldLabel="Prioridad" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="complejidadTB" 
                                            runat="server" 
                                            FieldLabel="Complejidad" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="tipoTB" 
                                            runat="server" 
                                            FieldLabel="Tipo" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>                                    
                                    <ext:Anchor>
                                        <ext:DateField 
                                            ID="fechaCreacionTB" 
                                            runat="server" 
                                            Width="150" 
                                            FieldLabel="Fecha Creacion" 
                                            Format="dd-MMM-yyyy"
                                            ReadOnly="true" 
                                            Disabled="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="estadoTB" 
                                            runat="server" 
                                            FieldLabel="Estado" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="tipo" 
                                            runat="server" 
                                            FieldLabel="Tipo" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="perfilTB" 
                                            runat="server" 
                                            FieldLabel="Perfil Requerido" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="seniorityTB" 
                                            runat="server" 
                                            FieldLabel="Seniority Requerido" 
                                            Width="150" 
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                    <ext:Anchor>
                                        <ext:TextField 
                                            ID="proyectoTB" 
                                            runat="server" 
                                            FieldLabel="Proyecto" 
                                            Width="150"
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>                                    
                                    <ext:Anchor>
                                        <ext:TextArea 
                                            ID="descripcionTB" 
                                            runat="server" 
                                            FieldLabel="Descripcion" 
                                            Height="50" 
                                            Width="150"
                                            ReadOnly="true" 
                                            />
                                    </ext:Anchor>
                                </ext:FormLayout>
                            </Body>
                        </ext:Panel>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <br />
                <ext:Button ID="nuevaTareaCM" runat="server" Text="Nueva Tarea" OnClientClick="Coolite.AjaxMethods.CargarPopupEditor(0)">
                </ext:Button>
            </td>
        </tr>
    </table>
    
     <uc2:EdTarea ID="EdTarea" runat="server" />     
    
    <uc1:EdAsignacionTarea ID="EdAsignacionTarea" runat="server" />
    
     
    
</asp:Content>
